package com.xuyiwei.mayi.test;

/**
 * Created by xuyiwei on 2019/4/13.
 */
class JoinThreadRunnable implements Runnable{
    @Override
    public void run() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        for(int i=0;i<50;i++){
            System.out.print(Thread.currentThread().getName()+i);
        }
        System.out.println();
    }
}
public class JoinThread {
    public static void main(String[] args) throws InterruptedException {
        JoinThreadRunnable runnable = new JoinThreadRunnable();
        Thread t1 = new Thread(runnable,"t1线程");
        Thread t2 = new Thread(runnable,"t2线程");
        t1.start();
        t2.start();
        t1.join();
        for(int i=0;i<100;i++){
            System.out.print("主线程"+i);
        }
    }
}
